package zhengyanze.com.aipoemmax.guide.guide;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.View;


/**
 * 懒加载根布局
 * Created by MrZheng on 2017/7/20.
 */

public abstract class BasLazyeFragment extends Fragment {

    //是否可见
    boolean isVIsibleToUser = false;

    //标记View(Fragment)是否初始化
    boolean isViewInit = false;

    //是否加载过动画
    boolean isDataInit = false;

    /**
     * 在Activity 完成其onCreated()回调之后调用
     * @param savedInstanceState
     */
    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        isViewInit = true;
        //第一次显示界面
        if (isViewInit && isVIsibleToUser && !isDataInit) {
            showAnimaort();
            isDataInit = true;
        }
    }

    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        this.isVIsibleToUser = isVisibleToUser;
        if (isVIsibleToUser && isViewInit && !isDataInit) {
            showAnimaort();
            isDataInit = true;
        }
    }

    /**
     * 显示动画
     */
    public abstract void showAnimaort();
}
